<?php
/**
 * Created by PhpStorm.
 * User: yangfan
 * Date: 2019/11/7
 * Time: 11:26 AM
 */

namespace App\BO\OrderStatus\State;

use App\BO\OrderStatus\IOperationJudgement;
use App\BO\OrderStatus\IOrderFlow;
use App\BO\OrderStatus\Meta\UserApplyRefundInfo;
use App\BO\OrderStatus\Meta\UserCancelInfo;
use App\BO\OrderStatus\OrderStateContext;
use App\BO\OrderStatus\OrderStateModifyStore;
use App\BO\PaymentState\Pay\PayInfo;
use App\Entities\OrderEntity;

abstract class AOrderState implements IOrderFlow, IOperationJudgement
{
    /**
     * @var OrderStateModifyStore
     */
    protected $orderStateModifyStore;

    /**
     * @var OrderStateContext
     */
    protected $stateContext;

    /**
     * 状态描述
     * @var string
     */
    protected $desc = '';

    /**
     * @return OrderEntity
     */
    protected function getOrder()
    {
        return $this->stateContext->getOrder();
    }

    /**
     * 返回状态描述
     * @return string
     */
    public function getDesc()
    {
        return $this->desc;
    }

    /**
     * @param OrderStateContext $stateContext
     */
    public function setStateContext(OrderStateContext $stateContext): void
    {
        $this->stateContext = $stateContext;
    }

    /**
     * @param OrderStateModifyStore $orderStateModifyStore
     */
    public function setOrderStateModifyStore(OrderStateModifyStore $orderStateModifyStore): void
    {
        $this->orderStateModifyStore = $orderStateModifyStore;
    }

    public function couldReport()
    {
        return false;
    }

    /**
     * 订单是否能转派
     * @return bool
     */
    public function couldReDispatch()
    {
        return false;
    }

    /**
     * 当前状态是否能进行派单操作
     * @return bool
     */
    public function couldDistribute()
    {
        return false;
    }

    /**
     * @return bool
     */
    public function couldAdminApplyRefund()
    {
        return false;
    }

    /**
     * 订单是否有服务信息
     * @return bool
     */
    public function hasServiceInfo()
    {
        return false;
    }

    /**
     * 是否有退款信息
     * @return bool
     */
    public function hasRefundInfo()
    {
        return false;
    }

    /**
     * 订单初始化操作
     */
    public function init()
    {
    }

    /**
     *  过期末支付
     */
    public function expire()
    {
    }

    /**
     * 分配订单动作
     * @return mixed
     */
    public function distribute()
    {
    }

    /**
     * 服务动作
     * @return mixed
     */
    public function service()
    {
    }


    /**
     * 服务开始
     * @return void
     */
    public function serviceStart()
    {
    }

    /**
     * 服务完成
     * @return void
     */
    public function serviceFinish()
    {
    }

    /**
     * 退款动作
     */
    public function refund()
    {
    }

    public function pay(PayInfo $payInfo)
    {
    }

    /**
     * 用户申请退款
     * @param UserApplyRefundInfo $userApplyRefundInfo
     */
    public function applyRefund(UserApplyRefundInfo $userApplyRefundInfo)
    {
    }

    /**
     * OA 管理员发起退款操作
     */
    public function adminApplyRefund()
    {
    }

    /**
     * 管理员拒绝退款
     * @return mixed
     */
    public function adminRejectRefund()
    {
    }

    /**
     * 管理员拒绝退款
     */
    public function userCancelledRefund()
    {
    }

    /**
     * 向第三方平台正式发起退款申请
     */
    public function applyThirdPartRefund()
    {
    }

    /**
     * 评价动作
     * @return mixed
     */
    public function comment()
    {
    }

    /**
     * 用户取消订单
     * @param UserCancelInfo $userCancelInfo
     */
    public function userCancel(UserCancelInfo $userCancelInfo)
    {
    }

    /**
     * 保洁员报备
     */
    public function report()
    {
    }

    /**
     * 保洁员取消报备
     * @return void
     */
    public function cleanerCancelReport()
    {
    }

    /**
     * @inheritDoc
     */
    public function adminAgreeReport()
    {
    }

    /**
     * @inheritDoc
     */
    public function adminRejectReport()
    {
    }

    /**
     * 设置为待上门状态
     */
    protected function toWaitingService()
    {
        $this->orderStateModifyStore->toWaitingService();
        $this->stateContext->setOrderState(OrderStateContext::getInstance(WaitingServiceState::class));
    }
}
